package Demo02;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class JspReq extends ActionSupport {
    @Override
    public String execute() throws Exception {
        //操作三个域对象,范围从小到大
        //1、request域
        HttpServletRequest request=ServletActionContext.getRequest();
        request.setAttribute("name","na1321me");

        //2、session域
//        HttpSession session= request.getSession();
//        session.setAttribute("name","na1321me");

        //3、ServletContext域
//        ServletContext context=ServletActionContext.getServletContext();
//        context.setAttribute("name","na1321me");

        return SUCCESS;
    }
}
